package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface SetmealDishMapper {


    @AutoFill(value = OperationType.INSERT)
    void save(Setmeal setmeal);


    List<Dish> addDish(Long id);

    void setmeal_dish(List<SetmealDish> setmealDishes);

    void insert(SetmealDish setmealDish);

    Page<SetmealVO> querySetmaelByPage(SetmealPageQueryDTO setmealPageQueryDTO);

    Setmeal getSetMeal(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Select("select * from setmeal where id = #{id}")
    SetmealVO setmealById(Long id);


    void add(List<SetmealDish> dish);

    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void delete(Long id);

    void deleteByIds(List<Long> ids);

    void deletesetmeal_dishByIds(Long id);

    @Select("select status from setmeal where id = #{id}")
    Integer selectStatus(Long id);

    void startOrstop(Integer change, Long setmealId);

    @Select("select status from setmeal where id = #{setmealId}")
    Integer getStatusById(Long setmealId);


    List<Setmeal> list(Setmeal setmeal);


    @Select("select sd.name, sd.copies, d.image, d.description " +
            "from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
            "where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> getDishItemBySetmealId(Long setmealId);


    void deleteByDish_id(Integer status,Long setmealid);

    @Select("select dish_id from setmeal_dish where setmeal_id = #{setmealId}")
    List<Long> getAllDishId(Long setmealId);
}
